
Partial Class Forms_Forms
    Inherits System.Web.UI.UserControl
    Implements IDashBoard

    Public Property Title() As String Implements IDashBoard.Title
        Get
            Return Me.TitleLabel.Text
        End Get
        Set(ByVal value As String)
            Me.TitleLabel.Text = value
        End Set
    End Property

    'Public Property Title() As String
    '    Get
    '        Return Me.TitleLabel.Text
    '    End Get
    '    Set(ByVal value As String)
    '        Me.TitleLabel.Text = value
    '    End Set
    'End Property
    Public Property SortDirection() As System.Web.UI.WebControls.SortDirection Implements IDashBoard.SortDirection
        Get
            Return FormsGridView.SortDirection
        End Get
        Set(ByVal value As System.Web.UI.WebControls.SortDirection)

        End Set
    End Property
    Public Property PageNumber() As Integer Implements IDashBoard.PageNumber
        Get
            Return Me.FormsGridView.PageIndex
        End Get
        Set(ByVal value As Integer)
            Me.FormsGridView.PageIndex = value
        End Set
    End Property

    Public Property PageSize() As Integer Implements IDashBoard.PageSize
        Get
            Return Me.FormsGridView.PageSize
        End Get
        Set(ByVal value As Integer)
            Me.FormsGridView.PageSize = value
            Me.NumberOfRowsDropDownList.SelectedValue = value.ToString
        End Set
    End Property

    Public Property SortField() As String Implements IDashBoard.SortField
        Get
            Return Me.FormsGridView.SortExpression
        End Get
        Set(ByVal value As String)
            '
        End Set
    End Property

    Protected Sub Page_Init(ByVal sender As Object, _
                            ByVal e As System.EventArgs) _
                            Handles Me.Init

        AddHandler NumberOfRowsDropDownList.SelectedIndexChanged, AddressOf NumberOfRowsDropDownList_SelectedIndexChanged

    End Sub


    Protected Sub Page_Load(ByVal sender As Object, _
                            ByVal e As System.EventArgs) _
                            Handles Me.Load

        If Not Me.IsPostBack Then
            BindGrid()
        Else
            AddHandler NumberOfRowsDropDownList.SelectedIndexChanged, AddressOf NumberOfRowsDropDownList_SelectedIndexChanged
        End If

    End Sub

    Public Sub SetScreenPositioning(ByVal displayRowsLeftPosition As Integer, _
                                    ByVal rightCornerLeftPosition As Integer, _
                                    ByVal headerWidth As Integer, _
                                    ByVal gridWidth As Integer)

        Dim usercontrolwidth As Integer = rightCornerLeftPosition + 9
        Dim middlecolumnwidth As Integer = usercontrolwidth - 18
        Dim displayspantabledata As Integer = displayRowsLeftPosition - 9

        Me.HeaderDiv.Style("width") = usercontrolwidth.ToString() & "px"
        Me.UserControlTable.Style("width") = usercontrolwidth.ToString() & "px"
        Me.GridTable.Style("width") = usercontrolwidth.ToString() & "px"
        Me.MiddleColumnTableData.Style("width") = middlecolumnwidth.ToString() & "px"
        Me.DisplaySpanTableData.Style("width") = (displayRowsLeftPosition - 9).ToString() & "px"
        Me.DisplayRowsTableData.Style("width") = (middlecolumnwidth - displayspantabledata).ToString() & "px"
        Me.FormsGridView.Width = Unit.Pixel(usercontrolwidth)


    End Sub

    Protected Sub NumberOfRowsDropDownList_SelectedIndexChanged(ByVal sender As Object, _
                                                                ByVal e As System.EventArgs) _
                                                                Handles NumberOfRowsDropDownList.SelectedIndexChanged

        If NumberOfRowsDropDownList.SelectedValue = "-1" Then
            Me.FormsGridView.AllowPaging = False
        Else
            Me.FormsGridView.AllowPaging = True
            Me.FormsGridView.PageSize = NumberOfRowsDropDownList.SelectedValue
            Me.FormsGridView.PageIndex = 0
            BindGrid()
        End If

    End Sub

    Public Sub BindGrid() Implements IDashBoard.BindGrid

        Me.FormsGridView.DataSource = Cdm.DataCore.CaseNotes.Forms.ListByRole(UserAuthorization.CurrentUser.RoleId, "FormLongName")
        Me.FormsGridView.DataBind()

    End Sub

    Protected Sub FormsGridView_PageIndexChanging(ByVal sender As Object, _
                                                  ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) _
                                                  Handles FormsGridView.PageIndexChanging

        Me.PageNumber = e.NewPageIndex

    End Sub

    Public Sub LoadControl1(ByVal sender As Object, _
                            ByVal e As System.EventArgs) _
                            Implements IDashBoard.LoadControl

        Me.Page_Load(sender, e)

    End Sub

End Class
